package lianxi;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;

public class _01_ {
	public static void main(String[] args) throws Exception {

		Class.forName("com.mysql.jdbc.Driver");

		Connection connection = DriverManager.getConnection("jdbc:mysql://127.0.0.1:3306/day_02", "root", "root");

		String sql = "select * from student_info";
		PreparedStatement PreparedStatement = connection.prepareStatement(sql);

		ResultSet resultSet = PreparedStatement.executeQuery(sql);

		while (resultSet.next()) {
			System.out.print(resultSet.getInt("id") + " ");
			System.out.print(resultSet.getString("stdno") + " ");
			System.out.print(resultSet.getString("name") + " ");
			System.out.print(resultSet.getString("classname") + " ");
			System.out.print(resultSet.getString("come_to_school_date") + " ");
			System.out.println(resultSet.getInt("age") + " ");

		}

		resultSet.close();
		PreparedStatement.close();
		connection.close();

	}
}
